import React, { Component } from 'react'
import { connect } from 'react-redux'
import {
  createdecrementAction,
  createincrementAction,
} from '../../redux/actions/count'

class Count extends Component {
  render() {
    let { personLength } = this.props
    return (
      <div>
        <h2>
          当前求和为{this.props.count} ,当前人数{personLength}
        </h2>
        <button onClick={this.add}>点我加1</button>
        <button onClick={this.decre}>点我减1</button>
      </div>
    )
  }
  add = () => {
    this.props.jia()
  }
  decre = () => {
    this.props.jian()
  }
}

export default connect(
  (state) => ({ count: state.count, personLength: state.person.length }),
  {
    jian: createdecrementAction,
    jia: createincrementAction,
  }
)(Count)
